package FilePanel.controls;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;

import javax.swing.JButton;

import FilePanel.Control;
import FilePanel.FilePanelControl;

/**
 * @author      Erwan Osouf, Lucas Ennouchi
 * @version     1.0                                
 * @since       29/01/2012
 */

public class ControlButton extends Control implements ActionListener{
	
	private JButton button;
	
	public ControlButton(JButton button) {
		super();
		this.button = button;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		String path = getSuperController().getView().getFileSelectionField().getText();
		getSuperController().setRoot(new File(path));
	}

	/**
	 * enables the button
	 * @param enabled
	 */
	public void setEnabled(boolean enabled) {
		this.button.setEnabled(enabled);
		System.out.println("set enabled "+enabled);
	}
}
